package fr.afcepf.atodcp2.benbai.servicesmetier.implementations;


import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import fr.afcepf.atodcp2.benbai.dao.interfaces.IDaoAuthentification;
import fr.afcepf.atodcp2.benbai.entity.Authentification;
import fr.afcepf.atodcp2.benbai.entity.Client;
import fr.afcepf.atodcp2.benbai.servicesmetier.interfaces.IMetierConnexion;

public class MetierConnexion implements IMetierConnexion {
	private Client client = new Client();
	private Authentification authen = new Authentification();
	private BeanFactory bf = new ClassPathXmlApplicationContext("benbaiSpringConf.xml");
	private IDaoAuthentification daoAuthentification = (IDaoAuthentification) bf.getBean("DaoAuthentification");
	
	@Override
	public boolean connexionClient(Client client) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean verifAuthentification(Authentification authentification) {
		
		boolean retour = false;
		try{
		this.authen = daoAuthentification.getAuthentificationByLoginMdp(authentification.getLogin(), authentification.getPwd());
		retour = true;		
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			retour = false;
		}
		
		return retour;
	}

}
